Proper fix to use an INI file instead of the registry on Windows

This commit is contained in:
Christophe Dumez 2010-07-16 15:03:18 +00:00
parent d354d7133e
commit b9241ad5ad
27 changed files with 311 additions and 313 deletions

View file

@ -64,6 +64,7 @@
#include "propertieswidget.h"
#include "statusbar.h"
#include "hidabletabwidget.h"
#include "qinisettings.h"
#ifdef Q_WS_MAC
#include "qmacapplication.h"
void qt_mac_set_dock_menu(QMenu *menu);
@ -352,7 +353,7 @@ void GUI::tab_changed(int new_tab) {
}
void GUI::writeSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("MainWindow"));
settings.setValue("geometry", saveGeometry());
// Splitter size
@ -414,7 +415,7 @@ void GUI::displayRSSTab() const {
// End of keyboard shortcuts slots
void GUI::readSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("MainWindow"));
restoreGeometry(settings.value("geometry").toByteArray());
const QStringList &sizes_str = settings.value("vSplitterSizes", QStringList()).toStringList();
@ -560,7 +561,7 @@ void GUI::showEvent(QShowEvent *e) {
// Called when we close the program
void GUI::closeEvent(QCloseEvent *e) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
const bool goToSystrayOnExit = settings.value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
if(!force_exit && systrayIcon && goToSystrayOnExit && !this->isHidden()) {
hide();
@ -619,7 +620,7 @@ bool GUI::event(QEvent * e) {
//Now check to see if the window is minimised
if(isMinimized()) {
qDebug("minimisation");
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(systrayIcon && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool()) {
if(!qApp->activeWindow() || !qApp->activeWindow()->isModal()) {
qDebug("Minimize to Tray enabled, hiding!");
@ -648,7 +649,7 @@ void GUI::dropEvent(QDropEvent *event) {
files = event->mimeData()->text().split(QString::fromUtf8("\n"));
}
// Add file to download list
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(QString file, files) {
file = file.trimmed().replace(QString::fromUtf8("file://"), QString::fromUtf8(""), Qt::CaseInsensitive);
@ -690,7 +691,7 @@ void GUI::dragEnterEvent(QDragEnterEvent *event) {
// Display a dialog to allow user to add
// torrents to download list
void GUI::on_actionOpen_triggered() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
// Open File Open Dialog
// Note: it is possible to select more than one file
const QStringList &pathsList = QFileDialog::getOpenFileNames(0,
@ -723,7 +724,7 @@ void GUI::processParams(const QString& params_str) {
}
void GUI::processParams(const QStringList& params) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(QString param, params) {
param = param.trimmed();
@ -754,7 +755,7 @@ void GUI::addTorrent(QString path) {
}
void GUI::processDownloadedFiles(QString path, QString url) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
@ -909,7 +910,7 @@ void GUI::showNotificationBaloon(QString title, QString msg) const {
*****************************************************/
void GUI::downloadFromURLList(const QStringList& url_list) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(const QString& url, url_list) {
if(url.startsWith("magnet:", Qt::CaseInsensitive)) {

View file

@ -31,7 +31,6 @@
#include <QDir>
#include <QDateTime>
#include <QString>
#include <QSettings>
#include <QNetworkInterface>
#include <QHostAddress>
#include <QNetworkAddressEntry>
@ -49,6 +48,7 @@
#endif
#include "torrentpersistentdata.h"
#include "httpserver.h"
#include "qinisettings.h"
#include "bandwidthscheduler.h"
#include <libtorrent/extensions/ut_metadata.hpp>
#include <libtorrent/version.hpp>
@ -2323,7 +2323,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
append_root_folder = true;
}
} else {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
if(!settings.value("ported_to_new_savepath_system", false).toBool()) {
append_root_folder = true;
}
@ -2517,7 +2517,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true);
}
}
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
settings.setValue("ported_to_new_savepath_system", true);
qDebug("Unfinished torrents resumed");
}

View file

@ -29,7 +29,6 @@
*/
#include <QTemporaryFile>
#include <QSettings>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkProxy>
@ -38,6 +37,7 @@
#include "downloadthread.h"
#include "preferences.h"
#include "qinisettings.h"
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
@ -170,7 +170,7 @@ void downloadThread::checkDownloadSize(qint64 bytesReceived, qint64 bytesTotal)
void downloadThread::applyProxySettings() {
QNetworkProxy proxy;
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
int intValue = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxyType"), 0).toInt();
if(intValue > 0) {
// Proxy enabled

View file

@ -36,7 +36,6 @@
#include "pluginsource.h"
#include <QProcess>
#include <QHeaderView>
#include <QSettings>
#include <QMenu>
#include <QMessageBox>
#include <QFileDialog>

View file

@ -32,7 +32,6 @@
#define FEEDDOWNLOADER_H
#include <QString>
#include <QSettings>
#include <QListWidget>
#include <QListWidgetItem>
#include <QInputDialog>
@ -45,6 +44,7 @@
#include "bittorrent.h"
#include "ui_feeddownloader.h"
#include "qinisettings.h"
#if QT_VERSION >= 0x040500
#include <QHash>
@ -168,20 +168,20 @@ public:
}
bool isDownloadingEnabled() const {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on", QHash<QString, QVariant>()).toHash();
return feeds_w_downloader.value(feed_url, false).toBool();
}
void setDownloadingEnabled(bool enabled) {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on", QHash<QString, QVariant>()).toHash();
feeds_w_downloader[feed_url] = enabled;
qBTRSS.setValue("downloader_on", feeds_w_downloader);
}
static FeedFilters getFeedFilters(QString url) {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> all_feeds_filters = qBTRSS.value("feed_filters", QHash<QString, QVariant>()).toHash();
return FeedFilters(url, all_feeds_filters.value(url, QHash<QString, QVariant>()).toHash());
}
@ -222,7 +222,7 @@ public:
}
void save() {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> all_feeds_filters = qBTRSS.value("feed_filters", QHash<QString, QVariant>()).toHash();
qDebug("Saving filters for feed: %s (%d filters)", qPrintable(feed_url), (*this).size());
all_feeds_filters[feed_url] = *this;

View file

@ -52,8 +52,7 @@
#include "headlessloader.h"
#endif
#include <QSettings>
#include "qinisettings.h"
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#include <signal.h>
#include <execinfo.h>
@ -95,7 +94,7 @@ class LegalNotice: public QObject {
public:
static bool userAgreesWithNotice() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(settings.value(QString::fromUtf8("LegalNotice/Accepted"), false).toBool()) // Already accepted once
return true;
#ifdef DISABLE_GUI
@ -203,7 +202,7 @@ int main(int argc, char *argv[]){
}
QString locale;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
#ifndef DISABLE_GUI
bool no_splash = false;
#endif

View file

@ -33,7 +33,6 @@
#include <QInputDialog>
#include <QSystemTrayIcon>
#include <QApplication>
#include <QSettings>
#include <QDialogButtonBox>
#include <QCloseEvent>
#include <QDesktopWidget>
@ -48,6 +47,7 @@
#include "misc.h"
#include "advancedsettings.h"
#include "scannedfoldersmodel.h"
#include "qinisettings.h"
// Constructor
options_imp::options_imp(QWidget *parent):QDialog(parent){
@ -296,7 +296,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
}
void options_imp::loadWindowState() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
resize(settings.value(QString::fromUtf8("Preferences/State/size"), sizeFittingScreen()).toSize());
QPoint p = settings.value(QString::fromUtf8("Preferences/State/pos"), QPoint()).toPoint();
if(!p.isNull())
@ -316,7 +316,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
}
void options_imp::saveWindowState() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue(QString::fromUtf8("Preferences/State/size"), size());
settings.setValue(QString::fromUtf8("Preferences/State/pos"), pos());
// Splitter size
@ -347,7 +347,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
void options_imp::saveOptions(){
applyButton->setEnabled(false);
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
// Apply style
useStyle();
settings.beginGroup("Preferences");

View file

@ -39,11 +39,11 @@
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QSet>
#include <QSettings>
#include <QHeaderView>
#include <QMenu>
#include <QClipboard>
#include <vector>
#include "qinisettings.h"
PeerListWidget::PeerListWidget(PropertiesWidget *parent): properties(parent), display_flags(false) {
// Visual settings
@ -255,7 +255,7 @@ void PeerListWidget::clear() {
}
void PeerListWidget::loadSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QList<int> contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth")).toStringList());
if(!contentColsWidths.empty()) {
for(int i=0; i<contentColsWidths.size(); ++i) {
@ -277,7 +277,7 @@ void PeerListWidget::loadSettings() {
}
void PeerListWidget::saveSettings() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList contentColsWidths;
for(int i=0; i<listModel->columnCount(); ++i) {
contentColsWidths << QString::number(columnWidth(i));

File diff suppressed because it is too large Load diff

View file

@ -52,6 +52,7 @@
#include "GUI.h"
#include "downloadedpiecesbar.h"
#include "pieceavailabilitybar.h"
#include "qinisettings.h"
#ifdef Q_WS_MAC
#define DEFAULT_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px; margin-left: 8px; margin-right: 8px;}"
@ -275,7 +276,7 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
}
void PropertiesWidget::readSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QList<int> contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/filesColsWidth")).toStringList());
if(contentColsWidths.empty()) {
filesList->header()->resizeSection(0, 300);
@ -301,7 +302,7 @@ void PropertiesWidget::readSettings() {
}
void PropertiesWidget::saveSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
QStringList contentColsWidths;
for(int i=0; i<PropListModel->columnCount(); ++i) {

View file

@ -48,13 +48,15 @@ public:
#ifdef Q_WS_WIN
QVariant value(const QString & key, const QVariant &defaultValue = QVariant()) const {
QVariant ret = QSettings::value(key);
if(format() == QSettings::NativeFormat && ret.isNull()) {
// Fallback on Windows, use \ in key instead of /
if(key.contains("/")) {
ret = QSettings::value(key.replace("/", "\\"));
} else {
if(key.contains("\\")) {
ret = QSettings::value(key.replace("\\", "/"));
if(format() == QSettings::NativeFormat) {
if(ret.isNull()) {
// Fallback on Windows, use \ in key instead of /
if(key.contains("/")) {
ret = QSettings::value(key.replace("/", "\\"));
} else {
if(key.contains("\\")) {
ret = QSettings::value(key.replace("\\", "/"));
}
}
}
}

View file

@ -310,7 +310,7 @@ void RssManager::updateRefreshInterval(unsigned int val){
}
void RssManager::loadStreamList(){
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
QStringList streamsUrl = settings.value("Rss/streamList").toStringList();
QStringList aliases = settings.value("Rss/streamAlias").toStringList();
if(streamsUrl.size() != aliases.size()){
@ -371,7 +371,7 @@ void RssManager::saveStreamList(){
streamsUrl << stream_path;
aliases << stream->getName();
}
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
settings.beginGroup("Rss");
// FIXME: Empty folder are not saved
settings.setValue("streamList", streamsUrl);
@ -383,7 +383,7 @@ void RssManager::saveStreamList(){
RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSession, QString _url): parent(parent), rssmanager(rssmanager), BTSession(BTSession), alias(""), iconPath(":/Icons/rss16.png"), refreshed(false), downloadFailure(false), currently_loading(false) {
qDebug("RSSStream constructed");
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
url = QUrl(_url).toString();
QHash<QString, QVariant> all_old_items = qBTRSS.value("old_items", QHash<QString, QVariant>()).toHash();
QVariantList old_items = all_old_items.value(url, QVariantList()).toList();
@ -402,7 +402,7 @@ RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSe
RssStream::~RssStream(){
qDebug("Deleting a RSS stream: %s", getName().toLocal8Bit().data());
if(refreshed) {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QVariantList old_items;
foreach(RssItem *item, this->values()) {
old_items << item->toHash();
@ -436,7 +436,7 @@ void RssStream::removeAllItems() {
}
void RssStream::removeAllSettings() {
QSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
QHash<QString, QVariant> feeds_w_downloader = qBTRSS.value("downloader_on", QHash<QString, QVariant>()).toHash();
if(feeds_w_downloader.contains(url)) {
feeds_w_downloader.remove(url);

View file

@ -34,7 +34,6 @@
#include <QFile>
#include <QList>
#include <QTemporaryFile>
#include <QSettings>
#include <QXmlStreamReader>
#include <QTime>
#include <QUrl>
@ -92,7 +91,7 @@ public:
enum FileType {STREAM, FOLDER};
RssFile(): QObject() {}
virtual ~RssFile() {};
virtual ~RssFile() {}
virtual unsigned int getNbUnRead() const = 0;
virtual FileType getType() const = 0;

View file

@ -250,7 +250,7 @@ void RSSImp::deleteSelectedItems() {
}
void RSSImp::loadFoldersOpenState() {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
settings.beginGroup("Rss");
QStringList open_folders = settings.value("open_folders", QStringList()).toStringList();
settings.endGroup();
@ -288,7 +288,7 @@ void RSSImp::saveFoldersOpenState() {
qDebug("saving open folder: %s", qPrintable(path));
open_folders << path;
}
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
settings.beginGroup("Rss");
settings.setValue("open_folders", open_folders);
settings.endGroup();
@ -513,14 +513,14 @@ void RSSImp::refreshTextBrowser() {
void RSSImp::saveSlidersPosition() {
// Remember sliders positions
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
settings.setValue("rss/splitter_h", splitter_h->saveState());
settings.setValue("rss/splitter_v", splitter_v->saveState());
qDebug("Splitters position saved");
}
void RSSImp::restoreSlidersPosition() {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
QByteArray pos_h = settings.value("rss/splitter_h", QByteArray()).toByteArray();
if(!pos_h.isNull()) {
splitter_h->restoreState(pos_h);

View file

@ -34,9 +34,9 @@
#include <QDir>
#include <QFileInfo>
#include <QSettings>
#include <QString>
#include <QTemporaryFile>
#include "qinisettings.h"
namespace {
const int PathColumn = 0;
@ -181,7 +181,7 @@ int ScanFoldersModel::findPathData(const QString &path) const {
return -1;
}
void ScanFoldersModel::makePersistent(QSettings &settings) {
void ScanFoldersModel::makePersistent(QIniSettings &settings) {
QStringList paths;
QList<QVariant> downloadInFolderInfo;
foreach (const PathData* pathData, m_pathList) {

View file

@ -36,7 +36,7 @@
#include <QStringList>
class FileSystemWatcher;
class QSettings;
class QIniSettings;
class ScanFoldersModel : public QAbstractTableModel {
Q_OBJECT
@ -61,7 +61,7 @@ public:
PathStatus setDownloadAtPath(int row, bool downloadAtPath);
bool downloadInTorrentFolder(const QString &filePath) const;
void makePersistent(QSettings &settings);
void makePersistent(QIniSettings &settings);
signals:
// The absolute paths of new torrent files in the scanned directories.

View file

@ -31,7 +31,6 @@
#include <QStandardItemModel>
#include <QHeaderView>
#include <QCompleter>
#include <QSettings>
#include <QMessageBox>
#include <QTemporaryFile>
#include <QSystemTrayIcon>
@ -54,6 +53,7 @@
#include "misc.h"
#include "preferences.h"
#include "searchlistdelegate.h"
#include "qinisettings.h"
#include "GUI.h"
#define SEARCHHISTORY_MAXSIZE 50
@ -260,15 +260,15 @@ void SearchEngine::on_enginesButton_clicked() {
connect(dlg, SIGNAL(enginesChanged()), this, SLOT(fillCatCombobox()));
}
// get the last searchs from a QSettings to a QStringList
// get the last searchs from a QIniSettings to a QStringList
void SearchEngine::startSearchHistory(){
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
searchHistory.setStringList(settings.value("Search/searchHistory",QStringList()).toStringList());
}
// Save the history list into the QSettings for the next session
// Save the history list into the QIniSettings for the next session
void SearchEngine::saveSearchHistory() {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
settings.setValue("Search/searchHistory",searchHistory.stringList());
}
@ -372,7 +372,7 @@ void SearchEngine::propagateSectionResized(int index, int , int newsize) {
void SearchEngine::saveResultsColumnsWidth() {
if(all_tab.size() > 0) {
QTreeView* treeview = all_tab.first()->getCurrentTreeView();
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
QStringList width_list;
QStringList new_width_list;
short nbColumns = all_tab.first()->getCurrentSearchListModel()->columnCount();
@ -547,7 +547,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
if(searchTimeout->isActive()) {
searchTimeout->stop();
}
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
bool useNotificationBalloons = settings.value("Preferences/General/NotificationBaloons", true).toBool();
if(useNotificationBalloons && parent->getCurrentTabIndex() != TAB_SEARCH) {
parent->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));

View file

@ -32,13 +32,13 @@
#include <QTreeView>
#include <QStandardItemModel>
#include <QHeaderView>
#include <QSettings>
#include <QSortFilterProxyModel>
#include "searchtab.h"
#include "searchlistdelegate.h"
#include "misc.h"
#include "searchengine.h"
#include "qinisettings.h"
#define SEARCH_NAME 0
#define SEARCH_SIZE 1
@ -111,7 +111,7 @@ QHeaderView* SearchTab::header() const {
}
bool SearchTab::loadColWidthResultsList() {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
QString line = settings.value("SearchResultsColsWidth", QString()).toString();
if(line.isEmpty())
return false;

View file

@ -33,7 +33,6 @@
#include <QDialog>
#include <QList>
#include <QSettings>
#include "ui_bandwidth_limit.h"
#include "misc.h"
#include "bittorrent.h"

View file

@ -21,9 +21,6 @@ DEFINES += VERSION_MINOR=3
DEFINES += VERSION_BUGFIX=0
win32 {
# Don't use the system registry on Windows
DEFINES += QSettings QIniSettings
# Adapt these paths on Windows
INCLUDEPATH += $$quote(C:/qbittorrent/msvc/boost_1_42_0)
INCLUDEPATH += $$quote(C:/qbittorrent/msvc/libtorrent-rasterbar-0.14.10/include)

View file

@ -37,11 +37,11 @@
#include <QDomNode>
#include <QDomElement>
#include <QProcess>
#include <QSettings>
#include <QDir>
#include <QApplication>
#include "misc.h"
#include "qinisettings.h"
class SearchCategories: public QObject, public QHash<QString, QString> {
Q_OBJECT
@ -74,7 +74,7 @@ public:
full_name = engine_elem.elementsByTagName("name").at(0).toElement().text();
url = engine_elem.elementsByTagName("url").at(0).toElement().text();
supported_categories = engine_elem.elementsByTagName("categories").at(0).toElement().text().split(" ");
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList disabled_engines = settings.value(QString::fromUtf8("SearchEngines/disabledEngines"), QStringList()).toStringList();
enabled = !disabled_engines.contains(name);
}
@ -87,7 +87,7 @@ public:
void setEnabled(bool _enabled) {
enabled = _enabled;
// Save to Hard disk
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList disabled_engines = settings.value(QString::fromUtf8("SearchEngines/disabledEngines"), QStringList()).toStringList();
if(enabled) {
disabled_engines.removeAll(name);

View file

@ -93,7 +93,7 @@ torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession
}
void torrentAdditionDialog::readSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
// Restore size and position
resize(settings.value(QString::fromUtf8("TorrentAdditionDlg/size"), size()).toSize());
move(settings.value(QString::fromUtf8("TorrentAdditionDlg/pos"), misc::screenCenter(this)).toPoint());
@ -109,7 +109,7 @@ torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession
}
void torrentAdditionDialog::saveSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(!is_magnet && t.get() && t->is_valid() && t->num_files() > 1) {
QStringList contentColsWidths;
// -1 because we hid PROGRESS column
@ -168,7 +168,7 @@ torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession
// Update display
updateDiskSpaceLabels();
// Load custom labels
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("TransferListFilters"));
QStringList customLabels = settings.value("customLabels", QStringList()).toStringList();
comboLabel->addItem("");
@ -265,7 +265,7 @@ torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession
connect(savePathTxt, SIGNAL(editTextChanged(QString)), this, SLOT(updateDiskSpaceLabels()));
updateDiskSpaceLabels();
// Load custom labels
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("TransferListFilters"));
const QStringList &customLabels = settings.value("customLabels", QStringList()).toStringList();
comboLabel->addItem("");
@ -616,7 +616,7 @@ torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession
}
void torrentAdditionDialog::saveTruncatedPathHistory() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
const QString current_save_path = getCurrentTruncatedSavePath();
// Get current history
QStringList history = settings.value("TorrentAdditionDlg/save_path_history").toStringList();
@ -636,6 +636,6 @@ torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession
}
QStringList torrentAdditionDialog::getSavePathHistory() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
return settings.value("TorrentAdditionDlg/save_path_history").toStringList();
}

View file

@ -37,7 +37,6 @@
#include <fstream>
#include <QMessageBox>
#include <QMenu>
#include <QSettings>
#include <QHeaderView>
#include <QApplication>
#include <QDesktopWidget>
@ -55,6 +54,7 @@
#include "preferences.h"
#include "GUI.h"
#include "transferlistwidget.h"
#include "qinisettings.h"
using namespace libtorrent;

View file

@ -31,7 +31,6 @@
#ifndef TORRENTPERSISTENTDATA_H
#define TORRENTPERSISTENTDATA_H
#include <QSettings>
#include <QVariant>
#include <QDateTime>
#include <libtorrent/version.hpp>
@ -39,6 +38,7 @@
#include "qtorrenthandle.h"
#include "misc.h"
#include <vector>
#include "qinisettings.h"
#if QT_VERSION < 0x040500
#include <QMap>
@ -51,13 +51,13 @@
class TorrentTempData {
public:
static bool hasTempData(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
return all_data.contains(hash);
}
static void deleteTempData(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
if(all_data.contains(hash)) {
all_data.remove(hash);
@ -66,7 +66,7 @@ public:
}
static void setFilesPriority(QString hash, const std::vector<int> &pp) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
std::vector<int>::const_iterator pp_it = pp.begin();
@ -81,7 +81,7 @@ public:
}
static void setFilesPath(QString hash, const QStringList &path_list) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
data["files_path"] = path_list;
@ -90,7 +90,7 @@ public:
}
static void setSavePath(QString hash, QString save_path) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
data["save_path"] = save_path;
@ -99,7 +99,7 @@ public:
}
static void setLabel(QString hash, QString label) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
qDebug("Saving label %s to tmp data", label.toLocal8Bit().data());
@ -109,7 +109,7 @@ public:
}
static void setSequential(QString hash, bool sequential) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
data["sequential"] = sequential;
@ -118,7 +118,7 @@ public:
}
static bool isSequential(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
if(data.contains("sequential"))
@ -129,7 +129,7 @@ public:
#if LIBTORRENT_VERSION_MINOR > 14
static void setSeedingMode(QString hash,bool seed){
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
data["seeding"] = seed;
@ -138,7 +138,7 @@ public:
}
static bool isSeedingMode(QString hash){
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
if(data.contains("seeding"))
@ -148,7 +148,7 @@ public:
#endif
static QString getSavePath(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
if(data.contains("save_path"))
@ -158,7 +158,7 @@ public:
}
static QStringList getFilesPath(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
if(data.contains("files_path"))
@ -167,7 +167,7 @@ public:
}
static QString getLabel(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
qDebug("Got label %s from tmp data", data.value("label", "").toString().toLocal8Bit().data());
@ -175,7 +175,7 @@ public:
}
static std::vector<int> getFilesPriority(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
std::vector<int> fp;
@ -193,19 +193,19 @@ class TorrentPersistentData {
public:
static bool isKnownTorrent(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
return all_data.contains(hash);
}
static QStringList knownTorrents() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
return all_data.keys();
}
static void setAddedDate(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
if(!data.contains("add_date")) {
@ -216,7 +216,7 @@ public:
}
static QDateTime getAddedDate(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
QDateTime dt = data.value("add_date", QDateTime()).toDateTime();
@ -228,7 +228,7 @@ public:
}
static void saveSeedDate(const QTorrentHandle &h) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
if(h.is_seed())
@ -240,14 +240,14 @@ public:
}
static QDateTime getSeedDate(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data.value("seed_date", QDateTime()).toDateTime();
}
static void deletePersistentData(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
if(all_data.contains(hash)) {
all_data.remove(hash);
@ -262,7 +262,7 @@ public:
TorrentTempData::deleteTempData(h.hash());
Q_ASSERT(!TorrentTempData::hasTempData(h.hash()));
// Save persistent data
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data;
data["is_magnet"] = is_magnet;
@ -284,7 +284,7 @@ public:
static void saveSavePath(QString hash, QString save_path) {
Q_ASSERT(!hash.isEmpty());
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
data["save_path"] = save_path;
@ -295,7 +295,7 @@ public:
static void saveLabel(QString hash, QString label) {
Q_ASSERT(!hash.isEmpty());
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
data["label"] = label;
@ -305,7 +305,7 @@ public:
static void saveName(QString hash, QString name) {
Q_ASSERT(!hash.isEmpty());
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
data["name"] = name;
@ -314,7 +314,7 @@ public:
}
static void savePriority(const QTorrentHandle &h) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
data["priority"] = h.queue_position();
@ -323,7 +323,7 @@ public:
}
static void saveSeedStatus(const QTorrentHandle &h) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
data["seed"] = h.is_seed();
@ -335,7 +335,7 @@ public:
// Getters
static QString getSavePath(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
//qDebug("TorrentPersistentData: getSavePath %s", data["save_path"].toString().toLocal8Bit().data());
@ -343,42 +343,42 @@ public:
}
static QString getLabel(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data.value("label", "").toString();
}
static QString getName(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data.value("name", "").toString();
}
static int getPriority(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data["priority"].toInt();
}
static bool isSeed(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data.value("seed", false).toBool();
}
static bool isMagnet(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data["is_magnet"].toBool();
}
static QString getMagnetUri(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
Q_ASSERT(data["is_magnet"].toBool());

View file

@ -31,7 +31,6 @@
#include <QTreeWidgetItem>
#include <QStringList>
#include <QMenu>
#include <QSettings>
#include <QHash>
#include <QAction>
#include <QColor>
@ -42,6 +41,7 @@
#include "trackersadditiondlg.h"
#include "misc.h"
#include "bittorrent.h"
#include "qinisettings.h"
TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
// Graphical settings
@ -372,7 +372,7 @@ void TrackerList::showTrackerListMenu(QPoint) {
}
void TrackerList::loadSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QList<int> contentColsWidths = misc::intListfromStringList(settings.value(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth")).toStringList());
if(!contentColsWidths.empty()) {
for(int i=0; i<contentColsWidths.size(); ++i) {
@ -384,7 +384,7 @@ void TrackerList::loadSettings() {
}
void TrackerList::saveSettings() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList contentColsWidths;
for(int i=0; i<columnCount(); ++i) {
contentColsWidths << QString::number(columnWidth(i));

View file

@ -35,7 +35,6 @@
#include <QListWidgetItem>
#include <QFrame>
#include <QIcon>
#include <QSettings>
#include <QVBoxLayout>
#include <QMenu>
#include <QInputDialog>
@ -45,6 +44,7 @@
#include "transferlistdelegate.h"
#include "transferlistwidget.h"
#include "qinisettings.h"
class LabelFiltersList: public QListWidget {
Q_OBJECT
@ -250,7 +250,7 @@ public:
}
void saveSettings() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("TransferListFilters"));
settings.setValue("selectedFilterIndex", QVariant(statusFilters->currentRow()));
//settings.setValue("selectedLabelIndex", QVariant(labelFilters->currentRow()));
@ -258,13 +258,13 @@ public:
}
void saveCustomLabels() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("TransferListFilters"));
settings.setValue("customLabels", QVariant(customLabels.keys()));
}
void loadSettings() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("TransferListFilters"));
statusFilters->setCurrentRow(settings.value("selectedFilterIndex", 0).toInt());
QStringList label_list = settings.value("customLabels", QStringList()).toStringList();

View file

@ -43,7 +43,6 @@
#include <QSortFilterProxyModel>
#include <QDesktopServices>
#include <QTimer>
#include <QSettings>
#include <QClipboard>
#include <QInputDialog>
#include <QColor>
@ -53,9 +52,11 @@
#include <QFileDialog>
#include <vector>
#include "qinisettings.h"
TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent *_BTSession):
QTreeView(parent), BTSession(_BTSession), main_window(main_window) {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
// Create and apply delegate
listDelegate = new TransferListDelegate(this);
setItemDelegate(listDelegate);
@ -573,7 +574,7 @@ inline QModelIndex TransferListWidget::mapFromSource(const QModelIndex &index) c
QStringList TransferListWidget::getCustomLabels() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
return settings.value("TransferListFilters/customLabels", QStringList()).toStringList();
}
@ -863,7 +864,7 @@ void TransferListWidget::recheckSelectedTorrents() {
// save the hidden columns in settings
void TransferListWidget::saveHiddenColumns() const {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
QStringList ishidden_list;
const short nbColumns = listModel->columnCount()-1;//hash column is hidden
@ -880,7 +881,7 @@ void TransferListWidget::saveHiddenColumns() const {
// load the previous settings, and hide the columns
bool TransferListWidget::loadHiddenColumns() {
QSettings settings("qBittorrent", "qBittorrent");
QIniSettings settings("qBittorrent", "qBittorrent");
const QString &line = settings.value("TransferListColsHoS", "").toString();
bool loaded = false;
const QStringList &ishidden_list = line.split(' ');
@ -1221,7 +1222,7 @@ void TransferListWidget::displayListMenu(const QPoint&) {
// Save columns width in a file to remember them
void TransferListWidget::saveColWidthList() {
qDebug("Saving columns width in transfer list");
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList width_list;
QStringList new_width_list;
const short nbColumns = listModel->columnCount()-1; // HASH is hidden
@ -1255,7 +1256,7 @@ void TransferListWidget::saveColWidthList() {
// Load columns width in a file that were saved previously
bool TransferListWidget::loadColWidthList() {
qDebug("Loading columns width for download list");
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString line = settings.value(QString::fromUtf8("TransferListColsWidth"), QString()).toString();
if(line.isEmpty())
return false;
@ -1290,7 +1291,7 @@ bool TransferListWidget::loadColWidthList() {
}
void TransferListWidget::saveLastSortedColumn() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
const Qt::SortOrder &sortOrder = header()->sortIndicatorOrder();
QString sortOrderLetter;
if(sortOrder == Qt::AscendingOrder)
@ -1303,7 +1304,7 @@ void TransferListWidget::saveLastSortedColumn() {
void TransferListWidget::loadLastSortedColumn() {
// Loading last sorted column
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortedCol = settings.value(QString::fromUtf8("TransferListSortedCol"), QString()).toString();
if(!sortedCol.isEmpty()) {
Qt::SortOrder sortOrder;