|
|
@ -795,28 +795,14 @@ bool GUI::hasFilteredFiles(const QString& fileName){ |
|
|
|
|
|
|
|
|
|
|
|
// Save last checked search engines to a file
|
|
|
|
// Save last checked search engines to a file
|
|
|
|
void GUI::saveCheckedSearchEngines(int) const{ |
|
|
|
void GUI::saveCheckedSearchEngines(int) const{ |
|
|
|
qDebug("Saving checked window size"); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QFile lastSearchEngines(misc::qBittorrentPath()+"lastSearchEngines.txt"); |
|
|
|
settings.beginGroup("SearchEngines"); |
|
|
|
// delete old file
|
|
|
|
settings.setValue("mininova", mininova->isChecked()); |
|
|
|
lastSearchEngines.remove(); |
|
|
|
settings.setValue("piratebay", piratebay->isChecked()); |
|
|
|
if(lastSearchEngines.open(QIODevice::WriteOnly | QIODevice::Text)){ |
|
|
|
settings.setValue("isohunt", isohunt->isChecked()); |
|
|
|
if(mininova->isChecked()) |
|
|
|
settings.setValue("meganova", meganova->isChecked()); |
|
|
|
lastSearchEngines.write(QByteArray("mininova\n")); |
|
|
|
settings.endGroup(); |
|
|
|
if(piratebay->isChecked()) |
|
|
|
qDebug("Saved checked search engines"); |
|
|
|
lastSearchEngines.write(QByteArray("piratebay\n")); |
|
|
|
|
|
|
|
// if(reactor->isChecked())
|
|
|
|
|
|
|
|
// lastSearchEngines.write(QByteArray("reactor\n"));
|
|
|
|
|
|
|
|
if(isohunt->isChecked()) |
|
|
|
|
|
|
|
lastSearchEngines.write(QByteArray("isohunt\n")); |
|
|
|
|
|
|
|
// if(btjunkie->isChecked())
|
|
|
|
|
|
|
|
// lastSearchEngines.write(QByteArray("btjunkie\n"));
|
|
|
|
|
|
|
|
if(meganova->isChecked()) |
|
|
|
|
|
|
|
lastSearchEngines.write(QByteArray("meganova\n")); |
|
|
|
|
|
|
|
lastSearchEngines.close(); |
|
|
|
|
|
|
|
qDebug("Saved checked search engines"); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
std::cerr << "Error: Could not save last checked search engines\n"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Save columns width in a file to remember them
|
|
|
|
// Save columns width in a file to remember them
|
|
|
@ -916,51 +902,14 @@ bool GUI::loadColWidthSearchList(){ |
|
|
|
// load last checked search engines from a file
|
|
|
|
// load last checked search engines from a file
|
|
|
|
void GUI::loadCheckedSearchEngines(){ |
|
|
|
void GUI::loadCheckedSearchEngines(){ |
|
|
|
qDebug("Loading checked search engines"); |
|
|
|
qDebug("Loading checked search engines"); |
|
|
|
QFile lastSearchEngines(misc::qBittorrentPath()+"lastSearchEngines.txt"); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QStringList searchEnginesList; |
|
|
|
settings.beginGroup("SearchEngines"); |
|
|
|
if(lastSearchEngines.exists()){ |
|
|
|
mininova->setChecked(settings.value("mininova", true).toBool()); |
|
|
|
if(lastSearchEngines.open(QIODevice::ReadOnly | QIODevice::Text)){ |
|
|
|
piratebay->setChecked(settings.value("piratebay", false).toBool()); |
|
|
|
QByteArray searchEngine; |
|
|
|
isohunt->setChecked(settings.value("isohunt", false).toBool()); |
|
|
|
while(!lastSearchEngines.atEnd()){ |
|
|
|
meganova->setChecked(settings.value("meganova", false).toBool()); |
|
|
|
searchEngine = lastSearchEngines.readLine(); |
|
|
|
settings.endGroup(); |
|
|
|
searchEnginesList << QString(searchEngine.data()); |
|
|
|
qDebug("Loaded checked search engines"); |
|
|
|
} |
|
|
|
|
|
|
|
lastSearchEngines.close(); |
|
|
|
|
|
|
|
if(searchEnginesList.indexOf("mininova\n") != -1){ |
|
|
|
|
|
|
|
mininova->setChecked(true); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
mininova->setChecked(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(searchEnginesList.indexOf("piratebay\n") != -1){ |
|
|
|
|
|
|
|
piratebay->setChecked(true); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
piratebay->setChecked(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// if(searchEnginesList.indexOf("reactor\n") != -1){
|
|
|
|
|
|
|
|
// reactor->setChecked(true);
|
|
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
|
|
// reactor->setChecked(false);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
if(searchEnginesList.indexOf("isohunt\n") != -1){ |
|
|
|
|
|
|
|
isohunt->setChecked(true); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
isohunt->setChecked(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// if(searchEnginesList.indexOf("btjunkie\n") != -1){
|
|
|
|
|
|
|
|
// btjunkie->setChecked(true);
|
|
|
|
|
|
|
|
// }else{
|
|
|
|
|
|
|
|
// btjunkie->setChecked(false);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
if(searchEnginesList.indexOf("meganova\n") != -1){ |
|
|
|
|
|
|
|
meganova->setChecked(true); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
meganova->setChecked(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
qDebug("Checked search engines loaded"); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
std::cerr << "Error: Could not load last checked search engines\n"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Display About Dialog
|
|
|
|
// Display About Dialog
|
|
|
@ -1054,19 +1003,11 @@ void GUI::dragEnterEvent(QDragEnterEvent *event){ |
|
|
|
// torrents to download list
|
|
|
|
// torrents to download list
|
|
|
|
void GUI::askForTorrents(){ |
|
|
|
void GUI::askForTorrents(){ |
|
|
|
QStringList pathsList; |
|
|
|
QStringList pathsList; |
|
|
|
QString lastDir = misc::qBittorrentPath()+"lastDir.txt"; |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QString dirPath=QDir::homePath(); |
|
|
|
|
|
|
|
QFile lastDirFile(lastDir); |
|
|
|
|
|
|
|
// Load remembered last dir
|
|
|
|
|
|
|
|
if(lastDirFile.exists()){ |
|
|
|
|
|
|
|
lastDirFile.open(QIODevice::ReadOnly | QIODevice::Text); |
|
|
|
|
|
|
|
dirPath=lastDirFile.readLine(); |
|
|
|
|
|
|
|
lastDirFile.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Open File Open Dialog
|
|
|
|
// Open File Open Dialog
|
|
|
|
// Note: it is possible to select more than one file
|
|
|
|
// Note: it is possible to select more than one file
|
|
|
|
pathsList = QFileDialog::getOpenFileNames(this, |
|
|
|
pathsList = QFileDialog::getOpenFileNames(this, |
|
|
|
tr("Open Torrent Files"), dirPath, |
|
|
|
tr("Open Torrent Files"), settings.value("MainWindowLastDir", QDir::homePath()).toString(), |
|
|
|
tr("Torrent Files")+" (*.torrent)"); |
|
|
|
tr("Torrent Files")+" (*.torrent)"); |
|
|
|
if(!pathsList.empty()){ |
|
|
|
if(!pathsList.empty()){ |
|
|
|
for(int i=0; i<pathsList.size(); ++i){ |
|
|
|
for(int i=0; i<pathsList.size(); ++i){ |
|
|
@ -1080,12 +1021,9 @@ void GUI::askForTorrents(){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Save last dir to remember it
|
|
|
|
// Save last dir to remember it
|
|
|
|
if(lastDirFile.open(QIODevice::WriteOnly | QIODevice::Text)){ |
|
|
|
QStringList top_dir = pathsList.at(0).split(QDir::separator()); |
|
|
|
QStringList top_dir = pathsList.at(0).split(QDir::separator()); |
|
|
|
top_dir.removeLast(); |
|
|
|
top_dir.removeLast(); |
|
|
|
settings.setValue("MainWindowLastDir", top_dir.join(QDir::separator())); |
|
|
|
lastDirFile.write(top_dir.join(QDir::separator()).toUtf8()); |
|
|
|
|
|
|
|
lastDirFile.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|