mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Improve lists columns state saving
This commit is contained in:
parent
e142aafea1
commit
596737ba2f
@ -49,6 +49,8 @@
|
|||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
PeerListWidget::PeerListWidget(PropertiesWidget *parent): QTreeView(parent), properties(parent), display_flags(false) {
|
PeerListWidget::PeerListWidget(PropertiesWidget *parent): QTreeView(parent), properties(parent), display_flags(false) {
|
||||||
|
// Load settings
|
||||||
|
loadSettings();
|
||||||
// Visual settings
|
// Visual settings
|
||||||
setRootIsDecorated(false);
|
setRootIsDecorated(false);
|
||||||
setItemsExpandable(false);
|
setItemsExpandable(false);
|
||||||
@ -77,8 +79,6 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent): QTreeView(parent), pro
|
|||||||
setItemDelegate(listDelegate);
|
setItemDelegate(listDelegate);
|
||||||
// Enable sorting
|
// Enable sorting
|
||||||
setSortingEnabled(true);
|
setSortingEnabled(true);
|
||||||
// Load settings
|
|
||||||
loadSettings();
|
|
||||||
// IP to Hostname resolver
|
// IP to Hostname resolver
|
||||||
updatePeerHostNameResolutionState();
|
updatePeerHostNameResolutionState();
|
||||||
// SIGNAL/SLOT
|
// SIGNAL/SLOT
|
||||||
@ -262,42 +262,12 @@ void PeerListWidget::clear() {
|
|||||||
|
|
||||||
void PeerListWidget::loadSettings() {
|
void PeerListWidget::loadSettings() {
|
||||||
QIniSettings 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());
|
header()->restoreState(settings.value("TorrentProperties/Peers/PeerListState").toByteArray());
|
||||||
if(!contentColsWidths.empty()) {
|
|
||||||
for(int i=0; i<contentColsWidths.size(); ++i) {
|
|
||||||
setColumnWidth(i, contentColsWidths.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Load sorted column
|
|
||||||
QString sortedCol = settings.value(QString::fromUtf8("TorrentProperties/Peers/PeerListSortedCol"), QString()).toString();
|
|
||||||
if(!sortedCol.isEmpty()) {
|
|
||||||
Qt::SortOrder sortOrder;
|
|
||||||
if(sortedCol.endsWith(QString::fromUtf8("d")))
|
|
||||||
sortOrder = Qt::DescendingOrder;
|
|
||||||
else
|
|
||||||
sortOrder = Qt::AscendingOrder;
|
|
||||||
sortedCol.chop(1);
|
|
||||||
int index = sortedCol.toInt();
|
|
||||||
sortByColumn(index, sortOrder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListWidget::saveSettings() const {
|
void PeerListWidget::saveSettings() const {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
QStringList contentColsWidths;
|
settings.setValue("TorrentProperties/Peers/PeerListState", header()->saveState());
|
||||||
for(int i=0; i<listModel->columnCount(); ++i) {
|
|
||||||
contentColsWidths << QString::number(columnWidth(i));
|
|
||||||
}
|
|
||||||
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths);
|
|
||||||
// Save sorted column
|
|
||||||
Qt::SortOrder sortOrder = header()->sortIndicatorOrder();
|
|
||||||
QString sortOrderLetter;
|
|
||||||
if(sortOrder == Qt::AscendingOrder)
|
|
||||||
sortOrderLetter = QString::fromUtf8("a");
|
|
||||||
else
|
|
||||||
sortOrderLetter = QString::fromUtf8("d");
|
|
||||||
int index = header()->sortIndicatorSection();
|
|
||||||
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/PeerListSortedCol"), QVariant(QString::number(index)+sortOrderLetter));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_resolution) {
|
void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_resolution) {
|
||||||
|
@ -61,8 +61,9 @@ using namespace libtorrent;
|
|||||||
|
|
||||||
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList):
|
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList):
|
||||||
QWidget(parent), transferList(transferList), main_window(main_window) {
|
QWidget(parent), transferList(transferList), main_window(main_window) {
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
loadFilesListState();
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
deleteWS_button->setIcon(IconProvider::instance()->getIcon("list-remove"));
|
deleteWS_button->setIcon(IconProvider::instance()->getIcon("list-remove"));
|
||||||
addWS_button->setIcon(IconProvider::instance()->getIcon("list-add"));
|
addWS_button->setIcon(IconProvider::instance()->getIcon("list-add"));
|
||||||
@ -129,6 +130,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra
|
|||||||
}
|
}
|
||||||
|
|
||||||
PropertiesWidget::~PropertiesWidget() {
|
PropertiesWidget::~PropertiesWidget() {
|
||||||
|
saveFilesListState();
|
||||||
delete refreshTimer;
|
delete refreshTimer;
|
||||||
delete trackerList;
|
delete trackerList;
|
||||||
delete peersList;
|
delete peersList;
|
||||||
@ -272,16 +274,18 @@ void PropertiesWidget::loadTorrentInfos(const QTorrentHandle &_h) {
|
|||||||
loadDynamicData();
|
loadDynamicData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesWidget::loadFilesListState() {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
|
filesList->header()->restoreState(settings.value("TorrentProperties/FilesListState").toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesWidget::saveFilesListState() {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
|
settings.setValue("TorrentProperties/FilesListState", filesList->header()->saveState());
|
||||||
|
}
|
||||||
|
|
||||||
void PropertiesWidget::readSettings() {
|
void PropertiesWidget::readSettings() {
|
||||||
QIniSettings 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);
|
|
||||||
} else {
|
|
||||||
for(int i=0; i<contentColsWidths.size(); ++i) {
|
|
||||||
filesList->setColumnWidth(i, contentColsWidths.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Restore splitter sizes
|
// Restore splitter sizes
|
||||||
QStringList sizes_str = settings.value(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString()).toString().split(",");
|
QStringList sizes_str = settings.value(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString()).toString().split(",");
|
||||||
if(sizes_str.size() == 2) {
|
if(sizes_str.size() == 2) {
|
||||||
@ -300,11 +304,6 @@ void PropertiesWidget::readSettings() {
|
|||||||
void PropertiesWidget::saveSettings() {
|
void PropertiesWidget::saveSettings() {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
|
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
|
||||||
QStringList contentColsWidths;
|
|
||||||
for(int i=0; i<PropListModel->model()->columnCount(); ++i) {
|
|
||||||
contentColsWidths << QString::number(filesList->columnWidth(i));
|
|
||||||
}
|
|
||||||
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
|
||||||
// Splitter sizes
|
// Splitter sizes
|
||||||
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
|
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
|
||||||
QList<int> sizes;
|
QList<int> sizes;
|
||||||
|
@ -95,6 +95,10 @@ public slots:
|
|||||||
void openDoubleClickedFile(QModelIndex);
|
void openDoubleClickedFile(QModelIndex);
|
||||||
void updateSavePath(const QTorrentHandle& h);
|
void updateSavePath(const QTorrentHandle& h);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void loadFilesListState();
|
||||||
|
void saveFilesListState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TransferListWidget *transferList;
|
TransferListWidget *transferList;
|
||||||
MainWindow *main_window;
|
MainWindow *main_window;
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
|
TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
|
||||||
|
loadSettings();
|
||||||
// Graphical settings
|
// Graphical settings
|
||||||
setRootIsDecorated(false);
|
setRootIsDecorated(false);
|
||||||
setAllColumnsShowFocus(true);
|
setAllColumnsShowFocus(true);
|
||||||
@ -71,7 +72,6 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
|
|||||||
lsd_item = new QTreeWidgetItem(QStringList("** "+tr("[LSD]")+" **"));
|
lsd_item = new QTreeWidgetItem(QStringList("** "+tr("[LSD]")+" **"));
|
||||||
insertTopLevelItem(2, lsd_item);
|
insertTopLevelItem(2, lsd_item);
|
||||||
setRowColor(2, QColor("grey"));
|
setRowColor(2, QColor("grey"));
|
||||||
loadSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackerList::~TrackerList() {
|
TrackerList::~TrackerList() {
|
||||||
@ -368,21 +368,12 @@ void TrackerList::showTrackerListMenu(QPoint) {
|
|||||||
|
|
||||||
void TrackerList::loadSettings() {
|
void TrackerList::loadSettings() {
|
||||||
QIniSettings 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(!header()->restoreState(settings.value("TorrentProperties/Trackers/TrackerListState").toByteArray())) {
|
||||||
if(!contentColsWidths.empty()) {
|
|
||||||
for(int i=0; i<contentColsWidths.size(); ++i) {
|
|
||||||
setColumnWidth(i, contentColsWidths.at(i));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setColumnWidth(0, 300);
|
setColumnWidth(0, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerList::saveSettings() const {
|
void TrackerList::saveSettings() const {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
QStringList contentColsWidths;
|
settings.setValue("TorrentProperties/Trackers/TrackerListState", header()->saveState());
|
||||||
for(int i=0; i<columnCount(); ++i) {
|
|
||||||
contentColsWidths << QString::number(columnWidth(i));
|
|
||||||
}
|
|
||||||
settings.setValue(QString::fromUtf8("TorrentProperties/Trackers/trackersColsWidth"), contentColsWidths);
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) :
|
|||||||
const Preferences pref;
|
const Preferences pref;
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
loadFilesListState();
|
||||||
// Icons
|
// Icons
|
||||||
CancelButton->setIcon(IconProvider::instance()->getIcon("dialog-cancel"));
|
CancelButton->setIcon(IconProvider::instance()->getIcon("dialog-cancel"));
|
||||||
OkButton->setIcon(IconProvider::instance()->getIcon("list-add"));
|
OkButton->setIcon(IconProvider::instance()->getIcon("list-add"));
|
||||||
@ -127,6 +128,7 @@ torrentAdditionDialog::~torrentAdditionDialog() {
|
|||||||
void torrentAdditionDialog::closeEvent(QCloseEvent *event)
|
void torrentAdditionDialog::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
saveFilesListState();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
QDialog::closeEvent(event);
|
QDialog::closeEvent(event);
|
||||||
}
|
}
|
||||||
@ -134,14 +136,24 @@ void torrentAdditionDialog::closeEvent(QCloseEvent *event)
|
|||||||
void torrentAdditionDialog::readSettings() {
|
void torrentAdditionDialog::readSettings() {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
restoreGeometry(settings.value("TorrentAdditionDlg/dimensions").toByteArray());
|
restoreGeometry(settings.value("TorrentAdditionDlg/dimensions").toByteArray());
|
||||||
torrentContentList->header()->resizeSection(0, 200); //Default
|
|
||||||
torrentContentList->header()->restoreState(settings.value("TorrentAdditionDlg/contentHeaderState").toByteArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrentAdditionDialog::saveSettings() {
|
void torrentAdditionDialog::saveSettings() {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
settings.setValue("TorrentAdditionDlg/dimensions", saveGeometry());
|
settings.setValue("TorrentAdditionDlg/dimensions", saveGeometry());
|
||||||
settings.setValue("TorrentAdditionDlg/contentHeaderState", torrentContentList->header()->saveState());
|
}
|
||||||
|
|
||||||
|
void torrentAdditionDialog::loadFilesListState() {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
|
if(!torrentContentList->header()->restoreState(settings.value("TorrentAdditionDlg/ContentHeaderState").toByteArray())) {
|
||||||
|
torrentContentList->header()->resizeSection(0, 200); //Default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void torrentAdditionDialog::saveFilesListState() {
|
||||||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
|
settings.setValue("TorrentAdditionDlg/ContentHeaderState", torrentContentList->header()->saveState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrentAdditionDialog::limitDialogWidth() {
|
void torrentAdditionDialog::limitDialogWidth() {
|
||||||
|
@ -46,8 +46,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
public:
|
public:
|
||||||
torrentAdditionDialog(QWidget *parent);
|
torrentAdditionDialog(QWidget *parent);
|
||||||
~torrentAdditionDialog();
|
~torrentAdditionDialog();
|
||||||
void readSettings();
|
|
||||||
void saveSettings();
|
|
||||||
void showLoadMagnetURI(QString magnet_uri);
|
void showLoadMagnetURI(QString magnet_uri);
|
||||||
void showLoad(QString filePath, QString from_url=QString::null);
|
void showLoad(QString filePath, QString from_url=QString::null);
|
||||||
QString getCurrentTruncatedSavePath(QString* root_folder_or_file_name = 0) const;
|
QString getCurrentTruncatedSavePath(QString* root_folder_or_file_name = 0) const;
|
||||||
@ -73,6 +71,12 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void readSettings();
|
||||||
|
void saveSettings();
|
||||||
|
void loadFilesListState();
|
||||||
|
void saveFilesListState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QString hash;
|
QString hash;
|
||||||
|
@ -65,6 +65,10 @@ using namespace libtorrent;
|
|||||||
|
|
||||||
TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, QBtSession *_BTSession):
|
TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, QBtSession *_BTSession):
|
||||||
QTreeView(parent), BTSession(_BTSession), main_window(main_window) {
|
QTreeView(parent), BTSession(_BTSession), main_window(main_window) {
|
||||||
|
|
||||||
|
// Load settings
|
||||||
|
loadSettings();
|
||||||
|
|
||||||
// Create and apply delegate
|
// Create and apply delegate
|
||||||
listDelegate = new TransferListDelegate(this);
|
listDelegate = new TransferListDelegate(this);
|
||||||
setItemDelegate(listDelegate);
|
setItemDelegate(listDelegate);
|
||||||
@ -120,9 +124,6 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
|
|||||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayListMenu(const QPoint&)));
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayListMenu(const QPoint&)));
|
||||||
header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
|
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
|
||||||
|
|
||||||
// Load settings
|
|
||||||
loadSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TransferListWidget::~TransferListWidget() {
|
TransferListWidget::~TransferListWidget() {
|
||||||
|
Loading…
Reference in New Issue
Block a user